package web.java.b_Statement;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import web.java.z_JDBCUtil.JDBCUtil;

public class Demo02_DML {
	/**
	 * 查询数据库
	 * */
	public static void main(String[] args) {
		Connection conn=JDBCUtil.connection();
		Statement stmt=null;
		ResultSet result=null;
		try {
			stmt=conn.createStatement();
			String sql="select * from emp";
			result=stmt.executeQuery(sql);
			while(result.next()){
				System.out.print(result.getInt("emp_id")+"\t");
				System.out.print(result.getString("emp_name")+"\t");
				System.out.print(result.getInt("emp_age")+"\t");
				System.out.print(result.getInt("emp_salary")+"\t");
				System.out.print(result.getInt("emp_consume")+"\t");
				System.out.print(result.getString("emp_gender"));
				System.out.println();
			}
			JDBCUtil.closeConn(conn, stmt, result);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
